home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 25 / CU Amiga Magazine's Super CD-ROM 25 (1998)(EMAP Images)(GB)(Track 1 of 2)[!][issue 1998-08].iso / CUCD / Programming / ixemul / sdk / man / cat3 / fopen.0 < prev    next >
Encoding:
Text File  |  1998-06-15  |  4.7 KB  |  99 lines

  1.  
  2. FOPEN(3)                   UNIX Programmer's Manual                   FOPEN(3)
  3.  
  4. NNAAMMEE
  5.      ffooppeenn, ffddooppeenn, ffrreeooppeenn - stream open functions
  6.  
  7. SSYYNNOOPPSSIISS
  8.      ##iinncclluuddee <<ssttddiioo..hh>>
  9.  
  10.      _F_I_L_E _*
  11.      ffooppeenn(_c_h_a_r _*_p_a_t_h, _c_h_a_r _*_m_o_d_e)
  12.  
  13.      _F_I_L_E _*
  14.      ffddooppeenn(_i_n_t _f_i_l_d_e_s, _c_h_a_r _*_m_o_d_e)
  15.  
  16.      _F_I_L_E _*
  17.      ffrreeooppeenn(_c_h_a_r _*_p_a_t_h, _c_h_a_r _*_m_o_d_e, _F_I_L_E _*_s_t_r_e_a_m)
  18.  
  19. DDEESSCCRRIIPPTTIIOONN
  20.      The ffooppeenn() function opens the file whose name is the string pointed to
  21.      by _p_a_t_h and associates a stream with it.
  22.  
  23.      The argument _m_o_d_e points to a string beginning with one of the following
  24.      sequences (Additional characters may follow these sequences.):
  25.  
  26.      ``r''   Open text file for reading.  The stream is positioned at the be-
  27.              ginning of the file.
  28.  
  29.      ``r+''  Open for reading and writing.  The stream is positioned at the
  30.              beginning of the file.
  31.  
  32.      ``w''   Truncate file to zero length or create text file for writing.
  33.              The stream is positioned at the beginning of the file.  It ``w+''
  34.              Open for reading and writing.  The file is created if it does not
  35.              exist, otherwise it is truncated.  The stream is positioned at
  36.              the beginning of the file.
  37.  
  38.      ``a''   Open for writing.  The file is created if it does not exist.  The
  39.              stream is positioned at the end of the file.
  40.  
  41.      ``a+''  Open for reading and writing.  The file is created if it does not
  42.              exist.  The stream is positioned at the end of the file.
  43.  
  44.      The _m_o_d_e string can also include the letter ``b'' either as a third char-
  45.      acter or as a character between the characters in any of the two-charac-
  46.      ter strings described above.  This is strictly for compatibility with AN-
  47.      SI C3.159-1989 (``ANSI C'') and has no effect; the ``b'' is ignored.
  48.  
  49.      Any created files will have mode "S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP |
  50.      S_IROTH | S_IWOTH" (0666), as modified by the process' umask value (see
  51.      umask(2)).
  52.  
  53.      Reads and writes may be intermixed on read/write streams in any order,
  54.      and do not require an intermediate seek as in previous versions of _s_t_d_i_o.
  55.      This is not portable to other systems, however; ANSI C requires that a
  56.      file positioning function intervene between output and input, unless an
  57.      input operation encounters end-of-file.
  58.  
  59.      The ffddooppeenn() function associates a stream with the existing file descrip-
  60.      tor, _f_i_l_d_e_s. The _m_o_d_e of the stream must be compatible with the mode of
  61.      the file descriptor.
  62.  
  63.      The ffrreeooppeenn() function opens the file whose name is the string pointed to
  64.      by _p_a_t_h and associates the stream pointed to by _s_t_r_e_a_m with it.  The
  65.      original stream (if it exists) is closed.  The _m_o_d_e argument is used just
  66.      as in the fopen function.  The primary use of the ffrreeooppeenn() function is
  67.      to change the file associated with a standard text stream (_s_t_d_e_r_r, _s_t_d_i_n,
  68.      or _s_t_d_o_u_t).
  69.  
  70. RREETTUURRNN VVAALLUUEESS
  71.      Upon successful completion ffooppeenn(), ffddooppeenn() and ffrreeooppeenn() return a FILE
  72.      pointer.  Otherwise, NULL is returned and the global variable _e_r_r_n_o is
  73.      set to indicate the error.
  74.  
  75. EERRRROORRSS
  76.      [EINVAL]      The _m_o_d_e provided to ffooppeenn(), ffddooppeenn(), or ffrreeooppeenn() was
  77.                    invalid.
  78.  
  79.      The ffooppeenn(), ffddooppeenn() and ffrreeooppeenn() functions may also fail and set _e_r_r_n_o
  80.      for any of the errors specified for the routine malloc(3).
  81.  
  82.      The ffooppeenn() function may also fail and set _e_r_r_n_o for any of the errors
  83.      specified for the routine open(2).
  84.  
  85.      The ffddooppeenn() function may also fail and set _e_r_r_n_o for any of the errors
  86.      specified for the routine fcntl(2).
  87.  
  88.      The ffrreeooppeenn() function may also fail and set _e_r_r_n_o for any of the errors
  89.      specified for the routines open(2),  fclose(3) and fflush(3).
  90.  
  91. SSEEEE AALLSSOO
  92.      open(2),  fclose(3),  fseek(3),  funopen(3)
  93.  
  94. SSTTAANNDDAARRDDSS
  95.      The ffooppeenn() and ffrreeooppeenn() functions conform to ANSI C3.159-1989 (``ANSI
  96.      C''). The ffddooppeenn() function conforms to IEEE Std1003.1-1988 (``POSIX'').
  97.  
  98. BSD Experimental                 June 4, 1993                                2
  99.